<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@3"></script>
    <style>
        .header {
            position: absolute
        }
    </style>
</head>
<body>
    <div id="root"></div>
</body>
<script>
    const app = Vue.createApp({
      data() {
        return {
          distance: 110
        }
      },
      template: `
        <div>
            <div v-pos:left="distance" class="header">
               <input />
            </div>
        </div>
      `
    });

    app.directive('pos', (el,binding) => {
         // binding.arg 值可以获得到 v-pos：后面传的值
         // 所以这里可以动态的获取
         el.style[binding.arg] = (binding.value + 'px');
    })
    const vm = app.mount("#root");
</script>
</html>